package io.renren.modules.work.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.work.entity.ScReportEntity;
import io.renren.modules.work.service.ScReportService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 报表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-25 20:45:09
 */
@RestController
@RequestMapping("work/screport")
public class ScReportController {
    @Autowired
    private ScReportService scReportService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("work:screport:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = scReportService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{reportid}")
    @RequiresPermissions("work:screport:info")
    public R info(@PathVariable("reportid") String reportid){
		ScReportEntity scReport = scReportService.getById(reportid);

        return R.ok().put("scReport", scReport);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("work:screport:save")
    public R save(@RequestBody ScReportEntity scReport){
		scReportService.save(scReport);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("work:screport:update")
    public R update(@RequestBody ScReportEntity scReport){
		scReportService.updateById(scReport);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("work:screport:delete")
    public R delete(@RequestBody String[] reportids){
		scReportService.removeByIds(Arrays.asList(reportids));

        return R.ok();
    }

}
